package HP.p0904;

import java.util.*;

public class Test2 {

    public static void main(String[] args) throws Exception {

        Student stu1 = new Student("wy", "1.1");
        Student stu2 = new Student("ls", "2.2");
        Student stu3 = new Student("zs", "3.3");

        List<Student> list = new ArrayList<Student>();

        list.add(stu1);
        list.add(stu2);
        list.add(stu3);
        // list.add("????");

        for (Student s : list) {
            // System.out.println(s.getId() + "\t" + s.getName());
        }

		/*
         * for (Object obj : list) { if (obj instanceof Student) { Student s =
		 * (Student) obj; System.out.println(s.getId() + "\t" + s.getName());
		 * }else { System.out.println(obj); } }
		 */
        Map<String, Student> map = new HashMap<String, Student>();

        map.put(",1", stu1);
        map.put("2,", stu2);
        map.put("3,", stu3);

        Collection<Student> c = map.values();

        Iterator<Student> it = c.iterator();


        while (it.hasNext()) {
            Student s = it.next();
            System.out.println(s.getStuClass() + "\t" + s.getName());
        }

        System.out.println(map.keySet());

    }

}
